package com.example.agenttest.controller;

import eu.bitwalker.useragentutils.Browser;
import eu.bitwalker.useragentutils.UserAgent;
import eu.bitwalker.useragentutils.Version;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
public class BrowserInfoController {

    @GetMapping
    public String info(HttpServletRequest request){
        Browser browser = UserAgent.parseUserAgentString(request.getHeader("User-Agent")).getBrowser();

        Version version = browser.getVersion(request.getHeader("User-Agent"));
        String info = browser.getName() + "/" + version.getVersion();

        return info;
    }
}
